#include "mytestsuite.h"

void mytestsuite::testInstruction(int id)
{
	switch(id)
	{
		case 0:
		{
			//Ici pas d'erreur, isValid doit être égal à 1
			functest.addInstruction(0,(string)"DECLARE",(string)"a ;");
			functest.addInstruction(1,(string)"DECLARE",(string)"b ;");
			functest.addInstruction(2,(string)"DECLARE",(string)"c ;");
			
			functest.addInstruction(3,(string)"AFFECTE",(string)"b 10;");
			functest.addInstruction(4,(string)"AFFECTE",(string)"a 10;");
			functest.addInstruction(5,(string)"AFFECTE",(string)"c + a b;");
			assert(functest.isValid()==1);
			break;
		}
		case 1:
		{
			//Ici il manque les déclarations de variables !!!
			functest.addInstruction(3,(string)"AFFECTE",(string)"b 10;");
			functest.addInstruction(4,(string)"AFFECTE",(string)"a 10;");
			functest.addInstruction(5,(string)"AFFECTE",(string)"c + a b;");
			assert(functest.isValid()==0);
			break;
		}
		case 2:
		{
			//Ici des fautes de frappes/casses
			functest.addInstruction(1,(string)"DECLARE",(string)"b ;");
			functest.addInstruction(3,(string)"AFFCTE",(string)"b 10;");
			assert(functest.isValid()==0);
			functest.addInstruction(4,(string)"declare",(string)"a;");
			assert(functest.isValid()==0);
			functest.addInstruction(5,(string)"AFFiche",(string)"c;");
			assert(functest.isValid()==0);
			break;
		}
		case 3:
		{
			//Test de la conformité des id
			
			//cout<<"'DECLARE kilo159 ; Valide'"<<endl;
			functest.addInstruction(1,(string)"DECLARE",(string)"kilo159 ;");
			assert(functest.isValid()==1);
			//cout<<"'DECLARE 152kilo ; Non Valide'"<<endl;
			functest.addInstruction(1,(string)"DECLARE",(string)"152kilo ;");
			assert(functest.isValid()==0);
			//cout<<"'DECLARE épée ; Non Valide'"<<endl;
			functest.addInstruction(1,(string)"DECLARE",(string)"épée ;");
			assert(functest.isValid()==0);
			break;
		}
		case 4:
		{
			functest.addInstruction(1,(string)"REPETE",(string)"10");
			assert(functest.isValid()==1);
			functest.addInstruction(2,(string)"REPETE",(string)"10 ;");
			assert(functest.isValid()==1);
			functest.addInstruction(3,(string)"RETOUR",(string)"10 ;");
			assert(functest.isValid()==1);
			break;
		}
	}
	
}

mytestsuite::mytestsuite():PTest("ProgrammeTest"),flux_err(),functest(0,"FonctionTest",flux_err)
{
	
}
